<?php defined('In33hao') or exit('Access Invalid!');?>
<div class="page">
  <div class="fixed-bar">
    <div class="item-title"><a class="back" href="index.php?act=store&op=list" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
      <div class="subject">
        <h3>供应商 - 编辑"</h3>
        <h5>商城供应商相关设置与管理</h5>
      </div>
    </div>
  </div>
  <!-- 操作说明 -->
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
      <h4 title="<?php echo $lang['nc_prompts_title'];?>"><?php echo $lang['nc_prompts'];?></h4>
      <span id="explanationZoom" title="<?php echo $lang['nc_prompts_span'];?>"></span> </div>
    <ul>
      <li>平台可以在此处添加供应商，新增的供应商默认为开启状态</li>
    </ul>
  </div>
  <form id="store_form" method="post">
    <input type="hidden" name="form_submit" value="ok" />
    <input type="hidden" name="store_id" value="<?php echo $output['store_array']['store_id']; ?>" />
  <input type="hidden" name="province_id" id="_area_1">
  <input type="hidden" name="city_id" id="_area_2">
  <input type="hidden" name="area_id" id="_area_3">
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label for="store_name"><em>*</em>供应商名称</label>
        </dt>
        <dd class="opt">
          <input type="text" value="<?php echo $output['store_array']['store_name']; ?>" id="store_name" name="store_name" class="input-txt"/>
          <span class="err"></span>
          <p class="notic"></p>
        </dd>
      </dl>
        <dl class="row">
            <dt class="tit">
                <label for="store_letters"><em>*</em>供应商首字母</label>
            </dt>
            <dd class="opt">
                <input type="text" value="<?php echo $output['store_array']['store_letters']; ?>" id="store_letters" name="store_letters" class="input-txt" />
                <span class="err"></span>
                <p class="notic">供应商全称首字母 （例：润丰科技 填 rfkj）</p>
            </dd>
        </dl>
      <div class="bot"><a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn"><?php echo $lang['nc_submit'];?></a></div>
    </div>
  </form>
</div>
<script type="text/javascript">
$(function(){
    $("#region").nc_region();
    //按钮先执行验证再提交表单
    $("#submitBtn").click(function(){
        if($("#store_form").valid()){
            $("#store_form").submit();
        }
    });

    $('#store_form').validate({
        errorPlacement: function(error, element){
            var error_td = element.parent('dd').children('span.err');
            error_td.append(error);
        },
        rules : {
            store_name: {
                required : true,
            },
            store_letters:{
                required : true,
            },
        },
        messages : {
            store_name: {
                required : '<i class="fa fa-exclamation-circle"></i>请输入供应商名称',
                remote   : '<i class="fa fa-exclamation-circle"></i>供应商名称已存在'
            },
            store_letters:{
                required : '<i class="fa fa-exclamation-circle"></i>请输入供应商缩写',
            },
        }
    });
});

    var store_type = document.getElementById('store_type').getElementsByTagName('input');
    var type  = document.getElementById('type');
    for (var i=0; i<store_type.length; i++){
          store_type[i].index = i;
          store_type[i].onclick = function(){
                 if(this.index==1){
                     type.style.display = 'none';
                 }else{
                     type.style.display = 'block';
                 }
          }
    }
</script> 
